package com.example.demo_yunpan.controller;

import com.example.demo_yunpan.entity.recycle;
import com.example.demo_yunpan.service.RecycleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RecycleController {
    @Autowired
    private RecycleService recycleService;

    //查询回收站
    @GetMapping("/recycle/{userId}")
    public List<recycle> getRecycleById(@RequestParam String userId){
        //查看是否传值成功
        System.out.println(userId);
        return recycleService.getRecycleById(userId);
    }

    //删除回收站文件
    @GetMapping("/recycle/{fileId}")
    public boolean delRecycleFile(@RequestParam String fileId){

        //删除数据库信息
        return recycleService.delRecycleFile(fileId);
    }

    //恢复回收站文件
    @GetMapping("/rstore")
    public boolean RestoreRecycleFile(@RequestParam String fileId){
        System.out.println(fileId);
        return recycleService.RestoreRecycleFile(fileId);
    }
}
